package org.zfes.snowier.cloud.zbss.pmp.router.service.pub;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.auth.shiro.util.SecurityUtil;
import org.zfes.snowier.cloud.zbss.pmp.dto.PmpWeeklyCreateDto;
import org.zfes.snowier.cloud.zbss.pmp.dto.PmpWeeklyUpdateDto;
import org.zfes.snowier.cloud.zbss.pmp.model.PmpWeekly;
import org.zfes.snowier.cloud.zbss.pmp.service.IPmpWeeklyService;
@Controller("org.zfes.snowier.cloud.zbss.pmp.router.service.pub.pmpWeeklyController") 
@RequestMapping("/pmp/service/pub/pmpWeekly")
public class PmpWeeklyController extends BaseController {

	
	@Autowired
	private IPmpWeeklyService pmpWeeklyService;
	
	
    @RequestMapping(value="/loadPmpWeeklyDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadPmpWeeklyDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  pmpWeeklyService.loadPmpWeeklyDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	
    @RequestMapping(value="/createPmpWeekly", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createPmpWeekly(PmpWeeklyCreateDto createDto){
		pmpWeeklyService.createPmpWeekly(SecurityUtil.getUserId().get(),createDto);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	
	
    @RequestMapping(value="/loadPmpWeekly", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadPmpWeekly(Long id){
		Optional<PmpWeekly> ops = pmpWeeklyService.loadPmpWeeklyById(id);
		return ajaxQuery("pmpWeekly",ops);
    }
	
	
    @RequestMapping(value="/updatePmpWeekly", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updatePmpWeekly(Long id,PmpWeeklyUpdateDto updateDto){
		pmpWeeklyService.updatePmpWeeklyByDev(id,updateDto);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	
    @RequestMapping(value="/submitPmpWeekly", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object submitPmpWeekly(Long id){
		pmpWeeklyService.submitPmpWeekly(id);;
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	
    @RequestMapping(value="/deletePmpWeekly", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deletePmpWeekly(Long id){
		pmpWeeklyService.deletePmpWeekly(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}